<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><{$_config.siteName}><{$_config.version}></title>
        <{$showjs}>
        <link rel="stylesheet" type="text/css" href="/Plug-in/ext/resources/css/xtheme-slate.css" />
        <{$ajax}>
        <link rel="stylesheet" type="text/css" href="./css/main.css"/>
    </head>
    <body style="background-color:#1c2642">
        <script>
            var lm, a,b,path,c,d,rh,rl,wh,wl,len;
            var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
            function toHex( n ) {
                var result = ''
                var start = true;
                for ( var i=32; i>0; ) {
                    i -= 4;
                    var digit = ( n >> i ) & 0xf;
                    if (!start || digit != 0) {
                        start = false;
                        result += digitArray[digit];
                    }
                }
                return ( result == '' ? '0' : result );
            }
            function testsuo(){
                try{	lm=new  ActiveXObject("Syunew3A.s_simnew3");
                    path=lm.FindPort(0);

                    if(lm.LastError!=0){
                        Ext.Msg.alert("IKEY检测错误","找不到相关的数字IKEY!");
                        return true;
                    }else{
                        return false;
                    }
                }
                catch (e){
                    Ext.Msg.alert("驱动","请安装驱动程序后再进行操作登录!");
                    return true;
                }
            }

            function cimgs(aaa){
                Ext.getDom('yzm').src="yzm.php?time="+new Date();
            }

            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'qtip';
                var simple = new Ext.FormPanel({
                    labelAlign: 'center',
                    labelWidth: 55,
                    baseCls: 'x-plain',
                    defaults: {width: 150},
                    monitorValid: true,
                    defaultType: 'textfield',//默认字段类型

                    //定义表单元素
                    items: [{
                            xtype:"combo",
                            fieldLabel:"系统语言",
                            mode:"local",
                            width:100,
                            sytle:'blod',
                            displayField:"htlang",
                            id:"htlang",
                            triggerAction:"all",
                            value:"中文简体",
                            readOnly:true,
                            listeners:{
                                select:function(_combo,_record,_index){
                                    if(_index==0){
                                        window.location.href='./changelg.php?HTLG=zh';
                                    }
                                    if(_index==1){
                                        window.location.href='./changelg.php?HTLG=en';
                                    }
                                }
                            },
                            store:new Ext.data.SimpleStore({
                                fields:["htlang"],
                                data:[["中文简体"]/*,["ENGLISH"]*/]
                            })
                        },{
                            xtype:"combo",
                            fieldLabel:"用户类型",
                            mode:"local",
                            width:100,
                            sytle:'blod',
                            displayField:"usertype",
                            id:"usertype",
                            triggerAction:"all",
                            value:"普通用户",
                            readOnly:true,
                            listeners:{
                                select:function(_combo,_record,_index){
                                    if(_index==2){
                                        if(true==testsuo()){
                                            this.setValue('普通用户');
                                        }else{
                                            lm.sWrite('123456',path);
                                            tempstrj=lm.sread(path);
                                            //alert(tempstrj);
                                            xajax_loadsuo(toHex(lm.GetID_1(path))+toHex(lm.GetID_2(path)),tempstrj);

                                        };
                                    }
                                }
                            },
                            store:new Ext.data.SimpleStore({
                                fields:["usertype"],
                                data:[["普通用户"]/*,["VIP用户"]*/,["IKEY用户"]]
                            })
                        },
                        {
                            //style:'background:url(/sa/img/Fwdw_icons_57.png) no-repeat center left',
                            cls : 'user',
                            fieldLabel: '帐户',
                            name: 'username',//元素名称
                            id:'username',
                            //anchor:'95%',//也可用此定义自适应宽度
                            width:180,
                            allowBlank:false,//不允许为空
                            blankText:'帐户不能为空'//错误提示内容
                        },{
                            cls : 'psw',
                            inputType:'password',
                            fieldLabel: '密码',
                            //anchor:'95%',
                            width:180,
                            name: 'password',
                            allowBlank:false,
                            blankText:'密码不能为空'
                        }
                        /*, {
                                cls : 'key',
                                name:'randCode',
                                id:'randCode',
                                fieldLabel:'验证码',
                                width:80,
                                allowBlank:false,
                                blankText:'验证码不能为空'
                                }*/
                        ,{
                            inputType:'hidden',
                            //fieldLabel: '密码',
                            //anchor:'95%',
                            name: 'action',
                            value:'loginz'
                            //allowBlank:false,
                            //blankText:'密码不能为空'
                        }
                    ],

                    keys:[{ //处理键盘回车事件
                            key:Ext.EventObject.ENTER,
                            fn:onOK,
                            scope:this
                        }],

                    buttons: [{
                            text: '登陆',
                            id:	'loginSubmit',
                            type: 'submit',

                            //定义表单提交事件
                            handler:function(){
                                if(simple.form.isValid()){//验证合法后使用加载进度条
                                    Ext.MessageBox.show({
                                        title: '请稍等',
                                        msg: '正在加载...',
                                        progressText: '',
                                        width:300,
                                        progress:true,
                                        closable:false,
                                        animEl: 'loding'
                                    });
                                    //控制进度速度
                                    var f = function(v){
                                        return function(){
                                            var i = v/11;
                                            Ext.MessageBox.updateProgress(i, '');
                                        };
                                    };

                                    for(var i = 1; i < 13; i++){
                                        setTimeout(f(i), i*150);
                                    }

                                    //提交到服务器操作
                                    simple.form.doAction('submit',{
                                        url:'./login.php',//文件路径
                                        method:'post',//提交方法post或get
                                        params:'{action:login}',
                                        //提交成功的回调函数
                                        success:function(form,action){
                                            if (action.result.msg=='ok') {
                                                document.location='index.php';
                                            } else {
                                                Ext.Msg.alert('登陆错误',action.result.msg);
                                                Ext.get('username').select();
                                            }
                                        },
                                        //提交失败的回调函数
                                        failure:function(){
                                           //Ext.Msg.alert('错误','服务器出现错误请稍后再试！');
                                        }
                                    });
                                }
                            },formBind:true
                        },{
                            text: '取消',
                            handler:function(){simple.form.reset();}//重置表单
                        }]
                });



                //确定按钮事件
                function onOK() {
                    Ext.getDom("loginSubmit").click();
                }


                //定义窗体
                win = new Ext.Window({
                    id:'win',
                    title:'<{$_config.siteName}><{$_config.version}>',
                    layout:'fit',	//之前提到的布局方式fit，自适应布局
                    width:320,
                    height:190,
                    bodyStyle:'padding:5px;',
                    maximizable:false,//禁止最大化
                    closeAction:'close',
                    closable:false,//禁止关闭
                    collapsible:true,//可折叠
                    plain: true,
                    buttonAlign:'center',
                    items:simple//将表单作为窗体元素嵌套布局
                });

                win.on('show',function(){
                    Ext.get('username').focus();
                }, this,{delay: 200});

                win.show();//显示窗体


            });
        </script>
    </body>
</html>
